package com.example.sys.pay.service;

import com.example.core.utils.SpringBeanUtils;
import com.example.sys.pay.po.SysPay;
import com.lly835.bestpay.model.PayResponse;
import org.springframework.stereotype.Service;

@Service
public class SysPayCommitService implements ISysPayService {

    private SysPayService sysPayService;

    public SysPayService getSysPayService() {
        if (sysPayService == null){
            sysPayService = (SysPayService) SpringBeanUtils.getBean(SysPayService.class);
        }
        return sysPayService;
    }

    @Override
    public void payExecute(PayResponse payResponse, SysPay sysPay) throws Exception {
        if (payResponse != null) {
            sysPay.setPayed(true);
            sysPay.setPayCode(payResponse.getOutTradeNo());
            this.getSysPayService().saveOrUpdate(sysPay);
        }
    }
}
